home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000121_icon-group-sender _Mon Apr 21 10:51:56 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 21 Apr 1997 13:23:26 MST
Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
id AA05136; Mon, 21 Apr 1997 13:23:26 -0700
Date: Mon, 21 Apr 1997 10:51:56 -0700
From: swampler@noao.edu (Steve Wampler)
Subject: Re: Comments on Icon Routine (redux)
To: icon-group@cs.arizona.edu
Message-Id: <swampler-9703211751.AA003815590@orpheus.gemini.edu>
In-Reply-To: <3358C3DD.23EE@airmail.net>
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1273
In thinking about Steve Graham's problem a bit more, it occurred to me
that some of the tests in the solution can be eliminated. Here's a
second solution that is a revised version of the earlier one (note that
the procedure ltrim has been improved slightly):
procedure main(args)
in := open(args[1], "r") | stop("Cannot open ", args[1])
out := open(args[2], "w") | stop("Cannot open ", args[2])
rmargin := args[3] | 80
while produce(out, read(in), rmargin)
end
procedure produce(f, s, rm)
ltrim(s) ? {
if reverse(move(rm)) ? { # line is too long...
suffix := reverse(tab(upto(' \t'))) | "" # ... split it apart
write(f, reverse(tab(0))) # ... print first part
} then # ... produce the rest of it
produce(f, suffix||tab(0), rm)
else # line is ok, print it
write(f, tab(0))
}
return
end
procedure ltrim(s) # return trimmed line
return s ? (tab(many(' ')), tab(0)) | tab(0)
end
--
Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
O Sibile, si ergo, fortibus es inero.
Nobile, demis trux. Demis phulla causan dux.